import java.util.HashMap;
import java.util.Map;

/**
 * @author LKQ
 * @date 2021/12/28 11:01
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        int[] products = {1,2,3,4,5,6,7}, prices = {100,200,300,400,300,200,100};
        Cashier cashier = new Cashier(3,50, products, prices);
        int[] product1 = {1,2}, amount1 = {1, 2};
        System.out.println(cashier.getBill(product1, amount1));
        int[] product2 = {3, 7}, amount2 = {10, 10};
        System.out.println( cashier.getBill(product2,amount2));

    }
}
class Cashier {
    private int n;
    private int discount;
    private Map<Integer, Integer> map;
    private int count = 0;
    public Cashier(int n, int discount, int[] products, int[] prices) {
        this.n = n;
        this.discount = discount;
        this.map = new HashMap<>();
        for (int i = 0; i < products.length; i++) {
            map.put(products[i], prices[i]);
        }
    }

    public double getBill(int[] product, int[] amount) {
        count++;
        double ans = 0;
        int m = product.length;
        for (int i = 0; i < m; i++) {
            // 客户买了n种商品
            ans += map.get(product[i]) * amount[i];
        }
        if (count % n == 0) {
            // 该打折了
            ans -= (discount * ans) / 100;
        }
        return ans;
    }
}

